package com.project.servlet;

import com.project.Util.UtfUtil;
import com.project.bean.ManBean;
import com.project.service.IManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;

/**
 * @author lyl
 * description:更新方法
 */
@Controller
public class UpdateServlet extends HttpServlet {
    @Autowired
    private IManService iManService;


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UtfUtil.utfUtil(req, resp);
        int manId = Integer.parseInt(req.getParameter("manId"));
        LocalDate birthday = LocalDate.parse(req.getParameter("birthday"));
        iManService.alt(manId, birthday);
        resp.sendRedirect("/findAll");
    }
}
